package com.ruicar.afs.cloud.product.enums;

/**
 * @author changyu.gui
 * @version 1.0
 * 产品模板类别
 * @date 2020/4/22 16:48
 */
public enum ProductTemplateCategoryEnum {
    MAIN_PRODUCTS("主产品属性", "1", new String[]{"10", "11"}),
    SUB_PRODUCTS("子产品属性", "2", new String[]{"01", "11"});
    private String name;
    private String value;
    private String[] range;

    // 构造方法
    private ProductTemplateCategoryEnum(String name, String value, String[] range) {
        this.name = name;
        this.value = value;
        this.range = range;
    }

    // 获取产品原子适用范围
    public static String[] getRange(String value) {
        for (ProductTemplateCategoryEnum c : ProductTemplateCategoryEnum.values()) {
            if (c.value.equals(value)) {
                return c.range;
            }
        }
        return null;
    }

    // 获取产品类别
    public static String getName(String value) {
        for (ProductTemplateCategoryEnum c : ProductTemplateCategoryEnum.values()) {
            if (c.value.equals(value)) {
                return c.name;
            }
        }
        return null;
    }
}
